#include "xtypes.h"
#include "xaux.h"
#include "xblob.h"
#include "xmemory.h"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


CxBlob::CxBlob()
{
	_Init();
}



CxBlob::CxBlob(const CxBlob& _Blob)
{
	_Init();
	_Copy(_Blob);
	return;
}


CxBlob& CxBlob::operator=(const CxBlob& _Blob)
{
	_Copy(_Blob);
	return *this;
}


CxBlob::CxBlob(int_t _Size)
{
	_Init();
	_Alloc(_Size);
}


CxBlob::~CxBlob()
{
	_Tidy();
}


void CxBlob::resize(int_t _Size)
{
	this->resize_capacity(_Size);
}


void CxBlob::fill(byte_t _Value)
{
	if(m_PhyPtr!=NULL)
	{
		memset(m_PhyPtr, _Value, m_PhySize);
	}
	return;
}


void CxBlob::fill_with(int_t _Offset, const wildptr_t _MemPtr, int_t _Size)
{
	if(_Offset+_Size<=m_PhySize)
	{
		memcpy(m_PhyPtr+_Offset, _MemPtr, _Size);
	}
	else
	{
		return;
	}
	return;
}


void CxBlob::bload(lpcstr_t lpszPathName)
{
	int_t nLength = xGetFileLength(lpszPathName);
	this->resize(nLength);

	xLoadMemoryBlock( m_PhyPtr, m_PhySize, lpszPathName );

}


void CxBlob::bsave(lpcstr_t lpszPathName)
{
	xSaveMemoryBlock( m_PhyPtr, m_PhySize, lpszPathName );
}



